<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="huoyun" uri="/huoyun"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>发布货源信息</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">

		<link rel="stylesheet" type="text/css"
			href="${pageContext.request.contextPath}/theme/css/main.css">
		<link rel="stylesheet" type="text/css"
			href="${pageContext.request.contextPath}/theme/css/style_userCenter.css">
		<script type="text/javascript"
			src="${pageContext.request.contextPath}/theme/js/jquery-1.6.js"></script>

		<script type="text/javascript"
			src="${pageContext.request.contextPath}/theme/js/calendar/WdatePicker.js"></script>
		<script type="text/javascript"
			src="${pageContext.request.contextPath}/theme/js/jquery.validate.js"></script>
		<script type="text/javascript"
			src="${pageContext.request.contextPath}/theme/js/additional-methods.js"
			charset="utf-8"></script>

		<script type="text/javascript">
	$(document).ready(function() {
		$("#cargoForm").validate({
			errorPlacement: function(error, element) {
				    // element.parent("td").append(error);
				     element.attr("title", error.html());
				   },
			rules : {
				"cargo.type" : {
					required : true
				},
				"cargo.title" : {
					required : true,
					maxlength : 50
				},
				"cargo.packageType" : {
					required : function(){
						return !$("#noPackage").is(":checked");
					}
				},
				"cargo.length" : {
					number : true,
					range : [0,1000]
				},
				"cargo.width" : {
					number : true,
					range : [0,1000]
				},
				"cargo.height" : {
					number : true,
					range : [0,1000]
				},
				"cargo.number" : {
					digits : true,
					range : [0,1000000]
				},
				"cargo.amount" : {
					required : function(){
						return $("#volume").val() == "";
					},
					number : true,
					range : [0,1000000]
				},
				"cargo.volume" : {
					required : function(){
						return $("#amount").val() == "";
					},
					number : true,
					range : [0,1000000]
				},
				"cargo.freight" : {
					number : true,
					range : [0,100000000]
				},
				"cargo.bidEndTime" : {
					required : true,
					moreThanToday : true
				},
				"cargo.otherInfo" : {
					maxlength : 200
				},
				"cargo.sender" : {
					required : true,
					maxlength : 10,
					chinese : true
				},
				"cargo.senderPhone" : {
					required : true,
					mobile : true
				},
				"cargo.startProvince" : {
					required : true
				},
				"cargo.startCity" : {
					required : true
				},
				"cargo.startTown" : {
					required : true
				},
				"cargo.startAddress" : {
					required : true,
					maxlength : 50
				},
				"cargo.loadStartTime" : {
					required : function(){
						return !$("#cancelLoadTime").is(":checked");
					},
					moreThanToday : function(){
						return !$("#cancelLoadTime").is(":checked");
					},
					lessThanEndDate : "cargo.loadEndTime"
				},
				"cargo.loadEndTime" : {
					moreThanStartDate : "cargo.loadStartTime"
				},
				"cargo.receiver" : {
					required : true,
					maxlength : 10,
					chinese : true
				},
				"cargo.receiverPhone" : {
					required : true,
					mobile : true
				},
				"cargo.destinationProvince" : {
					required : true
				},
				"cargo.destinationCity" : {
					required : true
				},
				"cargo.destinationTown" : {
					required : true
				},
				"cargo.destinationAddress" : {
					required : true,
					maxlength : 50
				},
				"cargo.unloadStartTime" : {
					required : function(){
						return !$("#cancelUnloadTime").is(":checked");
					},
					moreThanToday : function(){
						return !$("#cancelUnloadTime").is(":checked");
					},
					lessThanEndDate : "cargo.unloadEndTime"
				},
				"cargo.unloadEndTime" : {
					moreThanStartDate : "cargo.unloadStartTime"
				}
			},
			messages : {
				"cargo.type" : {
					required : "请选择货物类型"
				},
				"cargo.title" : {
					required : "请输入货物名称",
					maxlength : "货物名称的长度不能超过50个字符，请精简"
				},
				"cargo.packageType" : {
					required : "请选择货物的包装类型，如果货物没有包装类型，请勾选\"无包装\""
				},
				"cargo.length" : {
					number : "货物规格的长度必须为整数或小数，小数点后不超过2位",
					range : "货物规格的长度必须在0到1000之间"
				},
				"cargo.width" : {
					number : "货物规格的宽度必须为整数或小数，小数点后不超过2位",
					range : "货物规格的宽度必须在0到1000之间"
				},
				"cargo.height" : {
					number : "货物规格的高度必须为整数或小数，小数点后不超过2位",
					range : "货物规格的宽度必须在0到1000之间"
				},
				"cargo.number" : {
					digits : "货物总件数必须是整数",
					range : "货物总件数必须在0到100000000之间"
				},
				"cargo.amount" : {
					required : "货物总重量和总体积至少选填一个",
					number : "必须为整数或小数，小数点后不超过2位",
					range : "必须在0到1000000之间"
				},
				"cargo.volume" : {
					required : "货物总重量和总体积至少选填一个",
					number : "必须为整数或小数，小数点后不超过2位",
					range : "必须在0到1000000之间"
				},
				"cargo.freight" : {
					number : "必须为整数或小数，小数点后不超过2位",
					range : "必须在0到100000000之间"
				},
				"cargo.bidEndTime" : {
					required : "请输入应标截止时间",
					moreThanToday : "应标截止时间必须是一个将来时间"
				},
				"cargo.otherInfo" : {
					maxlength : "最多只能输入200个字符"
				},
				"cargo.sender" : {
					required : "请输入发货人姓名",
					maxlength : "发货人姓名不能超过10个字符",
					chinese : "只能输入中文"
				},
				"cargo.senderPhone" : {
					required : "请输入发货人手机号码"
				},
				"cargo.startProvince" : {
					required : "请选择起运地省市区"
				},
				"cargo.startCity" : {
					required : "请选择起运地省市区"
				},
				"cargo.startTown" : {
					required : "请选择起运地省市区"
				},
				"cargo.startAddress" : {
					required : "请输入起运地的详细地址（不需要输入省市区）",
					maxlength : "不能超过50个字符"
				},
				"cargo.loadStartTime" : {
					required : "请输入发货时间",
					moreThanToday : "发货时间必须是一个将来时间",
					lessThanEndDate : "发货开始时间必须小于发货结束时间"
				},
				"cargo.loadEndTime" : {
					moreThanStartDate : "发货结束时间必须大于发货开始时间"
				},
				"cargo.receiver" : {
					required : "请输入收货人的姓名",
					maxlength : "收货人姓名不能超过10个字符",
					chinese : "只能输入中文"
				},
				"cargo.receiverPhone" : {
					required : "请输入收货人手机号码"
				},
				"cargo.destinationProvince" : {
					required : "请选择目的地省市"
				},
				"cargo.destinationCity" : {
					required : "请选择目的地所在市区"
				},
				"cargo.destinationTown" : {
					required : "请选择目的地所在县区"
				},
				"cargo.destinationAddress" : {
					required : "请输入目的地的详细地址（不需要输入省市区）",
					maxlength : "不能超过50个字符"
				},
				"cargo.unloadStartTime" : {
					required : "请输入收货时间",
					moreThanToday : "收货时间必须是一个将来时间",
					lessThanEndDate : "收货开始时间必须小于收货结束时间"
				},
				"cargo.unloadEndTime" : {
					moreThanStartDate : "收货结束时间必须大于收货开始时间"
				}
				
			}
		});
	});
</script>
	</head>
	<body>
		<div>
			<jsp:include page="../userAdmin/nav.jsp">
				<jsp:param value="nav_main" name="nav" />
			</jsp:include>
		</div>
		<div class="realCer">
			<!--主体部分-->
			<div class="realMain clearfix mt10">
				<!--左侧菜单-->
				<div class="realLeft" id="meunLeft">
					<jsp:include page="../userAdmin/leftMenu.jsp">
						<jsp:param value="con_nav_main" name="con_nav" />
						<jsp:param value="cargoManagement" name="selectMenu"/>
					</jsp:include>
				</div>
				<!--中间-->
				<div class="realRight ml10">
					<div class="box">
						<div class="tit">
							<strong>修改货源信息</strong>
						</div>
						<div class="con">
							<div style="color: red; margin-left: 100px;">
								<s:property value="resultMsg" />
								<s:fielderror></s:fielderror>
							</div>
							<div class="form_wrap clearfix">
								<form method="post" id="cargoForm" name="cargoForm" action="editCargo.action" namespace="/cargo">
								<input type="hidden" name="cargo.id" value="<s:property value='cargo.id'/>"/>
									<table class="tableForm">
										<tbody>
											<tr>
												<td colspan="2">
													<h2>
														货物信息
													</h2>
												</td>
											</tr>
											<tr>
												<td class="tdLabel" width="120">
													<span class="required-field">*</span>货物名称：
												</td>
												<td class="tdValue">
													<huoyun:customSelect name="cargo.type" mode="cargosType"
														value="${cargo.type }" />
													&nbsp;
													<input class="text" type="text" name="cargo.title"
														id="title" style="width: 300px;"
														value="<s:property value='cargo.title'/>" />
													<label class="show">
														简要描述货物特征
													</label>
												</td>
											</tr>
											<tr>
												<td class="tdLabel">
													包装：
												</td>
												<td class="tdValue">
													<huoyun:customSelect id="packageType"
														name="cargo.packageType" mode="cargoPackageType"
														value="${cargo.packageType }" />
													&nbsp;
													<input type="checkbox" id="noPackage"
														onclick="changePackage()" />
													无包装
												</td>
											</tr>

											<tr id="specifications">
												<td class="tdLabel">
													规格：
												</td>
												<td class="tdValue">
													<span>
													<input class="text" type="text" style="width:50px;" name="cargo.length" id="length" value="<s:property value='cargo.length'/>" />
													X<input class="text" type="text" name="cargo.width" id="width" style="width:50px;" value="<s:property value='cargo.width'/>" />
													X<input class="text" type="text" name="cargo.height" id="height" style="width:50px;" value="<s:property value='cargo.height'/>" />
													&nbsp;米<sup>3</sup>
													</span>
													<span class="pl10">
													<input class="text" type="text" style="width:50px;" name="cargo.number" id="number" value="<s:property value='cargo.number'/>"/>&nbsp;件
													</span>
													<label class="show">
														货物包装的规格
													</label>
												</td>
											</tr>
											<tr>
												<td class="tdLabel">
													<span class="required-field">*</span>总重量：
												</td>
												<td class="tdValue">
													<input class="text" type="text" name="cargo.amount" style="width: 80px;"
														id="amount" value="<s:property value='cargo.amount'/>" />
													&nbsp;吨
													<span class="gray3">或</span> 总体积：
													<input class="text" type="text" name="cargo.volume" style="width: 80px;"
														id="volume" value="<s:property value='cargo.volume'/>" />
													&nbsp;米<sup>3</sup>
													<label class="show">
														货物总量在货物与车辆匹配中是非常重要的参数
													</label>
												</td>
											</tr>
											<tr>
												<td class="tdLabel">
													总运费：
												</td>
												<td class="tdValue">
													<input class="text" type="text" name="cargo.freight"
														id="freight" value="<s:property value='cargo.freight'/>" />
													<label class="show">
														总运费是作为车主选货参考的重要参数
													</label>
												</td>
											</tr>
											<tr>
												<td class="tdLabel">
													车型要求：
												</td>
												<td class="tdValue">
													<huoyun:customSelect name="cargo.carRequired"
														mode="carRequiredType" value="${cargo.carRequired }" />
												</td>
											</tr>
											<tr>
												<td class="tdLabel">
													<span class="required-field">*</span>应标截止日期：
												</td>
												<td class="tdValue">
													<input class="Wdate text" type="text"
														name="cargo.bidEndTime" id="bidEndTime"
														value="<huoyun:dateFormat date='${cargo.bidEndTime }' dateFormat='yyyy-MM-dd HH:mm'/>"
														onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})"
														readonly="readonly" />
													<label class="show">
														这个时间点以后不允许车辆竞标
													</label>
												</td>
											</tr>
											<tr>
												<td class="tdLabel">
													补充说明：
												</td>
												<td class="tdValue">
													<textarea name="cargo.otherInfo" cols="60" rows="3" id="otherInfo"><s:property value='cargo.otherInfo' /></textarea>
													<label class="show">
														可以添加特殊的要求说明
													</label>
												</td>
											</tr>
											<tr>
												<td colspan="2">
													<h2>
														发货信息
													</h2>
												</td>
											</tr>
											<tr>
												<td class="tdLabel">
													<span class="required-field">*</span>发货人姓名：
												</td>
												<td class="tdValue">
													<input class="text" type="text" name="cargo.sender"
														id="sender" value="<s:property value='cargo.sender'/>" />
													<label class="show">
														请如实填写发货人姓名
													</label>
												</td>
											</tr>
											<tr>
												<td class="tdLabel">
													<span class="required-field">*</span>发货人联系电话：
												</td>
												<td class="tdValue">
													<input class="text" type="text" name="cargo.senderPhone"
														id="senderPhone"
														value="<s:property value='cargo.senderPhone'/>" />
												</td>
											</tr>
											<tr>
												<td class="tdLabel">
													<span class="required-field">*</span>起运地：
												</td>
												<td class="tdValue">
													<huoyun:regionSelect provinceName="cargo.startProvince"
														cityName="cargo.startCity" townName="cargo.startTown"
														provinceValue="${cargo.startProvince }"
														cityValue="${cargo.startCity }"
														townValue="${cargo.startTown }" />
													<label class="show">
														获取当前所在地
													</label>
												</td>
											</tr>
											<tr>
												<td class="tdLabel">
													<span class="required-field">*</span>起运地街道地址：
												</td>
												<td class="tdValue">
													<input class="text" type="text" name="cargo.startAddress"
														id="startAddress" value="<s:property value='cargo.startAddress'/>" style="width:350px;" />
													<label class="show">
														请填写起始地街道地址
													</label>
												</td>
											</tr>
											<tr>
												<td class="tdLabel">
													<span id="loadTimeRequired" class="required-field">*</span>装货时间：
												</td>
												<td class="tdValue">
													<span id="loadTime"><input class="text Wdate"
															type="text" name="cargo.loadStartTime" id="loadStartTime"
															value="<huoyun:dateFormat date='${cargo.loadStartTime }' dateFormat='yyyy-MM-dd HH:mm'/>"
															onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})"
															readonly="readonly" /> <label>
															到
														</label> <input class="text Wdate" type="text"
															name="cargo.loadEndTime" id="loadEndTimec"
															value="<huoyun:dateFormat date='${cargo.loadEndTime }' dateFormat='yyyy-MM-dd HH:mm'/>"
															onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})"
															readonly="readonly" />
													</span>
													<input type="checkbox" name="" id="cancelLoadTime"
														onclick="changeInputDisplay(this, 'loadTime','loadTimeRequired')" />
													无限制
												</td>
											</tr>
											<tr>
												<td colspan="2">
													<h2>
														收货信息
													</h2>
												</td>
											</tr>
											<tr>
												<td class="tdLabel">
													<span class="required-field">*</span>收货人姓名：
												</td>
												<td class="tdValue">
													<input class="text" type="text" name="cargo.receiver"
														id="receiver" value="<s:property value='cargo.receiver'/>" />
													<label class="show">
														请填写收货人姓名
													</label>
												</td>
											</tr>
											<tr>
												<td class="tdLabel">
													<span class="required-field">*</span>收货人联系电话 ：
												</td>
												<td class="tdValue">
													<input class="text" type="text" name="cargo.receiverPhone"
														id="receiverPhone"
														value="<s:property value='cargo.receiverPhone'/>" />
												</td>
											</tr>
											<tr>
												<td class="tdLabel">
													<span class="required-field">*</span>目的地：
												</td>
												<td class="tdValue">
													<huoyun:regionSelect
														provinceName="cargo.destinationProvince"
														cityName="cargo.destinationCity"
														townName="cargo.destinationTown"
														provinceValue="${cargo.destinationProvince }"
														cityValue="${cargo.destinationCity }"
														townValue="${cargo.destinationTown }" />
													<label class="show">
														货物运送的地点
													</label>
												</td>
											</tr>
											<tr>
												<td class="tdLabel">
													<span class="required-field">*</span>目的地街道地址：
												</td>
												<td class="tdValue">
													<input class="text" type="text" name="cargo.destinationAddress"
														id="destinationAddress" value="<s:property value='cargo.destinationAddress'/>" style="width:350px" />
													<label class="show">
														请如实填写目的地街道地址
													</label>
												</td>
											</tr>
											<tr>
												<td class="tdLabel">
													<span id="unloadTimeRequired" class="required-field">*</span>收货时间：
												</td>
												<td class="tdValue">
													<span id="unloadTime"><input class="text Wdate"
															type="text" name="cargo.unloadStartTime"
															id="unloadStartTime"
															value="<huoyun:dateFormat date='${cargo.unloadStartTime }' dateFormat='yyyy-MM-dd HH:mm'/>"
															onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})"
															readonly="readonly" /> <label>
															到
														</label> <input class="text Wdate" type="text"
															name="cargo.unloadEndTime" id="unloadEndTime"
															value="<huoyun:dateFormat date='${cargo.unloadEndTime }' dateFormat='yyyy-MM-dd HH:mm'/>"
															onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})"
															readonly="readonly" />
													</span>
													<input type="checkbox" name="" id="cancelUnloadTime"
														onclick="changeInputDisplay(this, 'unloadTime','unloadTimeRequired')" />
													无限制
												</td>
											</tr>									
											<tr>
												<td></td>
												<td class="tdValue">
													<div class="button button-lorange">
														<input id="button_submit" type="submit" value="下一步" class="button-text">
													</div>
												</td>
											</tr>
										</tbody>
									</table>
			</form>
			<script type="text/javascript">
			$(function(){
				var packageType = "<s:property value='cargo.packageType'/>";
				if(packageType == null || packageType == "")
				{
					$("#noPackage").attr("checked", true);
				}
				else
				{
					$("#noPackage").attr("checked", false);
				}
				
				changePackage();
			
				var loadStartTime = "<s:property value='cargo.loadStartTime'/>";
				var loadEndTime = "<s:property value='cargo.loadEndTime'/>";
				if((loadStartTime == null || loadStartTime != "") && (loadEndTime == null || loadEndTime !=""))
				{
					$("#cancelLoadTime").attr("checked", true);
				}
				else
				{
					$("#cancelLoadTime").attr("checked", false);
				}
				
				changeInputDisplay($("#cancelLoadTime"), "loadTime");
				
				var unloadStartTime = "<s:property value='cargo.unloadStartTime'/>";
				var unloadEndTime = "<s:property value='cargo.unloadEndTime'/>";
				if((unloadStartTime == null || unloadStartTime == "") && (unloadEndTime == null || unloadEndTime ==""))
				{
					$("#cancelUnloadTime").attr("checked", true);
				}
				else
				{
					$("#cancelUnloadTime").attr("checked", false);
				}
				
				changeInputDisplay($("#cancelUnloadTime"), "unloadTime");
			});
			function changePackage()
			{
				if($("#noPackage").is(":checked"))
				{
					$("#packageType").hide();
					$("#specifications").hide();
					$("#packageType").val("");
					$("#length").val("");
					$("#width").val("");
					$("#height").val("");
				}
				else
				{
					$("#packageType").show();
					$("#specifications").show();
				}
			}
			
			function changeInputDisplay(obj, hiddenId,requiredId)
			{
				if($(obj).is(":checked"))
				{
					if(hiddenId != null && hiddenId != "" && $("#" + hiddenId))
					{	   
						$("#" + hiddenId).hide();
						$("#" + hiddenId).find("input").each(function(){
							$(this).val("");
						});
						
					}
					
					$("#" + requiredId).hide();
				}
				else
				{
					if(hiddenId != null && hiddenId != "" && $("#" + hiddenId))
					{
						$("#" + hiddenId).show();
					}
					
					$("#" + requiredId).show();
				}
			}
			</script>
			
							</div>

						</div>
					</div>
				</div>
				<!--中间-->
			</div>
		</div>

		<div>
			<jsp:include page="/footer.jsp"></jsp:include>
		</div>
	</body>
</html>
